package com.net.wanjian.networkhospitalmanager.activity;

import android.os.Build;
import android.os.Handler;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.activity.base.BaseActivity;
import com.net.wanjian.networkhospitalmanager.consts.SharedPreferencesKeyConst;
import com.net.wanjian.networkhospitalmanager.netstatus.NetUtils;
import com.net.wanjian.networkhospitalmanager.utils.SharedXmlUtil;

/**
 * Description:启动页面
 * Created by lidongcai on 2017/4/22.
 * Email:  lidongcaiocc@163.com
 */
public class SplashActivity extends BaseActivity {
    private final String FIRSTAPP = "firstapp";
    private final int DelayTIME = 2000;

    @Override
    protected void initData() {
        //保存设备标示码
        String serial = Build.SERIAL;
        SharedXmlUtil.getInstance().write(SharedPreferencesKeyConst.DEVICE_IDENTITY_KEY,serial);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                boolean first = SharedXmlUtil.getInstance().read(FIRSTAPP,false);
                if (first){
                    openActivity(LoginActivity.class);
//                    openActivity(SelectHospitalActivity.class);

                    finish();
                }else {
                    openActivity(SelectHospitalActivity.class);
                    SharedXmlUtil.getInstance().write(FIRSTAPP,true);
                    finish();
                }
            }
        },DelayTIME);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }
}
